#coding=utf-8
from time import sleep
from Models.class_partition import *

import os, shutil

usb_path = 'F:'
content = os.listdir(usb_path)
model_partition = class_partition()
disks = model_partition.get_system_disks()

disk_count = len(disks)

while True:
    new_disks = model_partition.get_system_disks()
    new_disk_count = len(new_disks)
    #difference = list(set(a).difference(set(b)))

    if new_disk_count > disk_count:
        print('程序监控到有U盘插入')
        # 取差集  数据集多的 数据集放前面  少的放后面
        diff_disks = list(set(new_disks).difference(set(disks)))

        for disk in  diff_disks:
            for root, dirs, files in os.walk(disk):
                print(files)
            list_files = os.listdir(disk)
            print(list_files)


    else:
        print('程序监控到无U盘插入')
        #break
        for root, dirs, files in os.walk('E:FlashFXP4_OYKSOFT/'):
            for name in  files:
                print(os.path.join(root, name))
            for name in dirs:
                print(os.path.join(root, name))

    sleep(3)
